﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace Common.Converters
{
    /// <summary>
    /// 多参数绑定
    /// </summary>
    public class MultiBindingConverter : IMultiValueConverter
    {
        /// <summary>
        /// Convert方法实现
        /// </summary>
        /// <param name="values">     </param>
        /// <param name="targetType"> </param>
        /// <param name="parameter">  </param>
        /// <param name="culture">    </param>
        /// <returns> </returns>
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            string ret = "";
            foreach (var item in values)
            {
                if (item is null)
                    continue;
                ret += item.ToString();
            }
            return ret;
        }

        /// <summary>
        /// ConvertBack方法实现
        /// </summary>
        /// <param name="value">       </param>
        /// <param name="targetTypes"> </param>
        /// <param name="parameter">   </param>
        /// <param name="culture">     </param>
        /// <returns> </returns>
        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => new[] { Binding.DoNothing, Binding.DoNothing };
    }
}